{
LANG : PASCAL
PROB : game1
}

program GAME1;
const
  fi = 'game1.in';
  fo = 'game1.out';
  max = 100;
var
  a : array[1..max] of longint;
  d : array[1..max, 1..max] of longint;
  n, sum : Longint;

procedure inp;
var
  i : longint;
begin
  read(n);
  for i := 1 to n do read(a[i]);
end;

procedure init;
var
  i : integer;
begin
  sum := 0;
  for i := 1 to n do inc(sum, a[i]);
  for i := 1 to n do d[i, i] := a[i];
end;

function max2(x, y : longint) : longint;
begin
  if x > y then max2 := x
  else max2 := y;
end;

procedure process;
var
  i, j, l : integer;
begin
  for l := 2 to n do
    for i := 1 to n-l+1 do
    begin
      j := i+l-1;
      d[i, j] := max2(a[i] - d[i+1, j], a[j] - d[i, j-1]);
    end;
end;

procedure out;
begin
  writeln((sum+d[1, n]) div 2, ' ', (sum-d[1, n]) div 2);
end;

begin
  assign(input, fi); reset(input);
  assign(output, fo); rewrite(output);
  inp;
  init;
  process;
  out;
  close(output);
  close(input);
end.